<?php
$cnn = mysql_connect("localhost","root","123");
mysql_select_db("looker",$cnn);
mysql_query("SET CHARSET utf8");
$ret = array();
$sql = "SELECT * FROM looker_site";
$res = mysql_query($sql);
while($row=mysql_fetch_assoc($res)){
	$ret[$row["sitehash"]] = $row;
	$ssql = "SELECT * FROM looker_category WHERE sitehash=".$row["sitehash"];
	$rres = mysql_query($ssql);
	while($rrow = mysql_fetch_assoc($rres)){
		$ret[$row["sitehash"]]['categorys'][] = $rrow;	
	}
}

print_r($ret);

echo json_encode($ret);


?>